# -*- coding: utf-8 -*-
import cgi
import datetime
import wsgiref.handlers

from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp

import views.Role as rv 

import decorator as dc

class RoleContr( webapp.RequestHandler ):
    def debug_self(self, what, action, params, kwds):
        self.response.out.write("(%s)" % what)
        self.response.out.write("\n<br>" + action )
        for (i,p) in enumerate(params):
            self.response.out.write("\n<br>param %d = %s" % (i,p) )
        self.response.out.write("\n<br>kwds=%s" % str(kwds) )
        self.response.out.write("\n<br>url=%s" % ( self.request.url ) )
        self.response.out.write("\n<br>args=%s" % ( self.request.arguments() ) )
        for name in self.request.arguments():
            self.response.out.write("\n<br>arg: <b>%s</b>=%s" % ( name, self.request.get(name) ) )

        self.response.out.write( repr(type(rv)) )   ; self.response.out.write("\n<br>")
        self.response.out.write( repr(rv.__name__) ); self.response.out.write("\n<br>")
        self.response.out.write( repr(rv.__path__) ); self.response.out.write("\n<br>")
        self.response.out.write( repr(rv.__doc__) ) ; self.response.out.write("\n<br>")
        self.response.out.write( repr(rv.__file__) ); self.response.out.write("\n<br>")
        self.response.out.write( str((type(rv),dir(rv)))) ; self.response.out.write("\n<br>")

    @dc.decorate
    def get(self, action, *params, **kwds):

        self.debug_self('get', action, params, kwds)
            
        if action == 'showAll': 
            self.response.out.write(rv.showAll( *params, **kwds ))
        
